﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
///CategoryDescription 的摘要说明
/// </summary>
public class Category
{
    public Category()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    private int categoryid;

    public int CategoryId
    {
        get { return categoryid; }
        set { categoryid = value; }
    }
    private string categorydescription;

    public string CategoryDescription
    {
        get { return categorydescription; }
        set { categorydescription = value; }
    }
    private string categoryname;

    public string CategoryName
    {
        get { return categoryname; }
        set { categoryname = value; }
    }

    public static Category ConvertToCategory(DataRow dr)
    {
        if (dr == null)
            return null;
        Category category = new Category();
        if (dr["CategoryId"] != null)
            category.CategoryId = Convert.ToInt32(dr["CategoryId"]);
        if (dr["CategoryDescription"] != null)
            category.CategoryDescription = dr["CategoryDescription"].ToString();
        if (dr["CategoryName"] != null)
            category.CategoryName = dr["CategoryName"].ToString();
        return category;

    }

    public static IList<Category> ConvertToCategoryList(DataTable dt)
    {
        List<Category> categorylist = new List<Category>();
        foreach (DataRow dr in dt.Rows)
        {
            Category category = ConvertToCategory(dr);
            if (category != null)
                categorylist.Add(category);
        }
        return categorylist;
    }
}
